/*
 * @Author: 向日葵
 * @Date: 2021-12-23 13:28:41
 * @Last Modified by: 向日葵
 * @Last Modified time: 2021-12-23 15:24:37
 */
package admin

import (
	"jwgin/model/mysql"
	"jwgin/service"

	"github.com/gin-gonic/gin"
)


//赛程赛果
type scheduler struct{}

func (s *scheduler) Routers(Router *gin.RouterGroup) (R gin.IRoutes) {
	Router.GET("sg/:statu", s.get)   //赛果
	return Router
}

// /admin/saicheng/0?page=1
func (l *scheduler) get(c *gin.Context) {
	status:=c.Param("statu")
	count, size, offset := pages(c)
	// ?startTime = 123123123
	startTime := c.Query("startTime")
	endTime := c.Query("endTime")
	db:=service.G.Model(mysql.Scheduler{})
	if startTime != "" && endTime != "" {
		db = db.Where(" `mt` > ? AND `mt` < ? ", startTime, endTime)
	}
	data := make([]map[string]interface{},0)
	err := db.Where("status = ?",  status).Count(&count).Limit(size).Offset(offset).Order("begin1, lsid, id  asc").Scan(&data).Error
	if err != nil {
		RespErr(c,err)
	}
	RespList(c,count,data)
}